function fmriqasheet(q)

% motion detection run?
if isfield(q, 'MotCorr') && ...
    isstruct(q.MotCorr) && ...
    isfield(q.MotCorr, 'Params')
    m = true;
else
    m = false;
end

% create figure
qs = figure;
set(qs, 'Visible', 'off');

% get ROOT object properties
rp = get(0);
rs = rp.ScreenSize;
rc = 0.5 .* rs(3:4);
if (rs(3) / rs(4)) >= sqrt(0.5)
    rs = 2 * round(0.45 * [sqrt(0.5) * rs(4), rs(4)]);
else
    rs = 2 * round(0.45 * [rs(3), sqrt(0.5) * rs(3)]);
end

% make figure settings
set(qs, ...
    'NumberTitle', 'off', ...
    'Name', 'fMRI data quality sheet', ...
    'Position', [rc - 0.5 * rs, rs]);
figure(qs);

% add subplots for output
if ~m
    cols = 1;
    targets = 1:3;
else
    cols = 2;
    targets = [1:2:6, 2:2:6];
end

% get some numbers
nvol = size(q.TC.Slices, 1);
nslc = size(q.TC.Slices, 2);

% plot PSC time courses or slices with outliers marked
tcp = subplot(3, cols, targets(1));
plot(2 * repmat(0:(nslc - 1), nvol, 1) + psctrans(q.TC.TF_ForeSlicesWeighted) - 100);
hold(tcp, 'on');
olm = uint8(zeros(2 * nslc, nvol, 3));
olm(:, :, 1) = 255;
olh = image(olm, 'Parent', tcp);
olm = repmat(0.25 * log(1 + q.Quality.Outliers.Volumes'), 2 * nslc, 1);
set(olh, 'AlphaData', olm);

% show overall global signal-to-noise ratio info
subplot(3, cols, targets(2));
image(repmat(uint8(floor(packmosaic(scaledata(q.Quality.GlobalSNRImage)))), [1, 1, 3]));

% and histogram of SNR
subplot(3, cols, targets(3));
hist(q.Quality.GlobalSNRImage(q.Masks.Foreground), 250);

% print out some info
line = repmat('-', 1, 72);
disp('fMRI Quality statistics:');
disp(line);
disp(sprintf(' - data dimensions:   %d x %d x %d', q.Dims(1:3)));
disp(sprintf(' - number of volumes: %d', q.Dims(4)));
disp(sprintf(' - outlier volumes:   %d (%.1f%%) [ %s]', ...
    sum(q.Quality.Outliers.Volumes > 2), 100*q.Quality.Outliers.VolumeRatio, ...
    sprintf('%d ', find(q.Quality.Outliers.Volumes > 2))));
disp(line);
disp(sprintf(' - average spatial  SNR: %-6.2f', ...
    mean(q.Quality.GlobalSNRImage(q.Masks.Foreground))))
disp(sprintf(' - average temporal SNR: %-6.2f', ...
    mean(q.Quality.LocalSNRImage(q.Masks.Foreground))))

% motion correction stuff
if m
    % text info
    maxmot = max(q.MotCorr.Params, [], 1) - min(q.MotCorr.Params, [], 1);
    disp(line);
    disp(sprintf(' - maximal translation: %-5.3fmm  %-5.3fmm  %-5.3fmm', maxmot(1:3)));
    disp(sprintf(' - maximal rotation:    %-5.3fdeg %-5.3fdeg %-5.3fdeg', maxmot(4:6)));
    
    % parameters
    subplot(3, cols, targets(4));
    plot(q.MotCorr.Params);
    
    % SNR over time
    subplot(3, cols, targets(5));
    image(repmat(uint8(floor(packmosaic(scaledata(q.Quality.LocalSNRImage)))), [1, 1, 3]));
    
    % important time courses
    subplot(3, cols, targets(6));
    plot(3 * repmat(0:(size(q.TC.Quality, 2) - 1), nvol, 1) + q.TC.Quality);
end
